/* Copyright (C) 2009 by Pavel Savara
This file is part of of jni4net - bridge between Java and .NET
http://jni4net.sourceforge.net/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package net.sf.jni4net.tested;

import net.sf.jni4net.Bridge;

/**
 * @author Pavel Savara (original)
 */
public class JavaCallStaticMethods {
	public static String stringMethod(String data) {
		return "stringMethod" + data;
	}

	public static String stringArrayMethod(String[] data) {
		return "stringArrayMethod-" + data.length;
	}

	public static void voidMethod(Object data) {
		System.out.println(data);
	}

    public static TestDelegate testDelegate(){
        return new TestDelegate(){
            public system.Object Invoke(int i, java.lang.String s){
                final system.String string = Bridge.convert(s + i);
                return string;
            }
        };
    }

    public static void testDelegatePtr() {

        final CIfcImpl ici=new CIfcImpl();
        system.Object res= ici.getfcePtr().Invoke(6,"test");

        ici.setfcePtr(new TestDelegate() {
            public system.Object Invoke(int i, java.lang.String s) {
                return Bridge.convert(s+i);
            }
        });
        ici.RunPtr();
        final system.Object object = ici.getfcePtr().Invoke(6, "nazdar");
    }

    public static void testDelegateEvent() {
        CIfcImpl ici=new CIfcImpl();
        ici.addEnvDispatcher(new TestDelegate() {
            public system.Object Invoke(int i, java.lang.String s) {
                return Bridge.convert(s+i);
            }
        });
        ici.RunEvnt();
    }


}
